package za.ac.wits.elen7045.exceptions;



import java.text.SimpleDateFormat;
import java.util.Date;

import za.ac.wits.elen7045.xml.writer.APSErrorToXml;

/**
 * @author ed
 * @Date 3/6/2012
 * 
 * This is the Abstract Base Class for the Error Handling Framework.
 * The framework is based on the Template Method design Pattern.
 *
 */


@SuppressWarnings("serial")
public abstract class APSException extends RuntimeException {

	
	
	protected Date today;
	protected SimpleDateFormat dateTimeFormatter;
	protected String currentTime;
	protected String errorCode;
	protected String baseUrl;
	
	
	protected  void generateErrorObjectToXml(APSException anApsException) {
		APSErrorToXml apsErrorToXml = new APSErrorToXml();
		apsErrorToXml.createXmlErrorFile(anApsException);	
	}
	
	public String getDate() {
		
		dateTimeFormatter = new SimpleDateFormat("dd/MM/yyyy");
		Date today = new Date();
		String stringDate = dateTimeFormatter.format(today);
		return stringDate;
	}
	
	public String getTime() {
		dateTimeFormatter = new SimpleDateFormat("HH:mm:ss");
		currentTime = dateTimeFormatter.format(today);
		return currentTime;
		
	}
	
	protected abstract void setBaseUrl(String abaseUrl);
	
	public abstract String getErrorCode();
	
	public abstract String getBaseUrl();
	
	
		

}